{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Sebastian Raschka   \n",
    "last updated: 04/14/2014  \n",
    "\n",
    "[Link to this IPython Notebook on GitHub](https://github.com/rasbt/pattern_classification/blob/master/stat_pattern_class/supervised/parametric/parameter_estimation/maximum_likelihood_estimate.ipynb)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<hr>\n",
    "I am really looking forward to your comments and suggestions to improve and extend this tutorial! Just send me a quick note   \n",
    "via Twitter: [@rasbt](https://twitter.com/rasbt)  \n",
    "or Email: [bluewoodtree@gmail.com](mailto:bluewoodtree@gmail.com)\n",
    "<hr>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#Maximum Likelihood Estimation for Statistical Pattern Classification"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Sections\n",
    "\n",
    "- [Introduction](#introduction)\n",
    "- [1) A simple case where the parameters are known - no MLE required](#one)\n",
    "    - [Generating some sample data](#sample_data)\n",
    "    - [Plotting the sample data](#plotting_data)\n",
    "    - [Defining the objective function and decision rule](#objective_function)\n",
    "    - [Implementing the discriminant function](#discriminant_functions)\n",
    "    - [Implementing the decision rule (classifier)](#decision_rule)\n",
    "    - [Classifying our sample data](#classifying)\n",
    "    - [Drawing the confusion matrix and calculating the empirical error](#confusion_matrix)\n",
    "- [2) Assuming that the parameters are unknown - using MLE](#two)\n",
    "    - [About the Maximum Likelihood Estimate (MLE)](#about_mle)\n",
    "    - [MLE of the mean vector $\\pmb \\mu$](#mle_mu)\n",
    "    - [MLE of the covariance matrix $\\pmb \\Sigma$](#mle_cov)\n",
    "    - [Classification using our estimated parameters](#classifying_mle)\n",
    "    - [Conclusion](#conclusion)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<br>\n",
    "<br>\n",
    "<a name='introduction'></a>\n",
    "# Introduction"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Popular applications for Maximum Likelihood Estimates are the typical statistical pattern classification tasks, and in the past, I posted some [examples](https://github.com/rasbt/pattern_classification#param) using Bayes' classifiers for which the **probabilistic models and parameters were known**. In those cases, the design of the classifier was rather easy, however, in real applications, we are rarely given this information; this is where the Maximum Likelihood Estimate comes into play."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "However, the Maximum Likelihood Estimate still **requires partial knowledge** about the problem: We have to assume that the **model of the class conditional densities is known** (e.g., that the data follows typical Gaussian distribution). In contrast, non-parametric approaches like the Parzen-window technqiue do not require prior information about the distribution of the data (I will discuss this technique in more detail in a future article, the IPython notebook is already in preparation).  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**To summarize the problem:** Using MLE, we want to estimate the values of the parameters of a given distribution for the class-conditional densities, for example, the *mean* and *variance* assuming that the class-conditional densities are *normal*  distributed (Gaussian) with $p(\\pmb x \\; | \\; \\omega_i) \\sim N(\\mu, \\sigma^2)$."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To illustrate the problem with an example, we will first take a look at a case where we already know the parameters, and then we will use the same dataset and estimate the parameters. This will give us some idea about the performance of the classifier using the estimated parameters. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<br>\n",
    "<br>\n",
    "<a name='one'></a>\n",
    "# 1) A simple case where the parameters are known - no MLE required"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Imagine that we want to classify data consisting of two-dimensional patterns, $\\pmb{x} = [x_1, x_2]^t$ that could belong to 1 out of 3 classes $\\omega_1,\\omega_2,\\omega_3$. \n",
    "\n",
    "Let's assume the following information about the model and the parameters are known:\n",
    "\n",
    "####model: continuous univariate normal (Gaussian) model for the class-conditional densities\n",
    "\n",
    "\n",
    "$ p(\\pmb x | \\omega_j) \\sim N(\\pmb \\mu|\\Sigma) $\n",
    "\n",
    "$ p(\\pmb x | \\omega_j) \\sim \\frac{1}{(2\\pi)^{d/2} \\; |\\Sigma|^{1/2}} exp \\bigg[ -\\frac{1}{2}(\\pmb x - \\pmb \\mu)^t \\Sigma^{-1}(\\pmb x - \\pmb \\mu) \\bigg]$\n",
    "\n",
    "$p([x_1, x_2]^t |\\omega_1) ∼ N([0,0]^t,3I), \\\\\n",
    "p([x_1, x_2]^t |\\omega_2) ∼ N([9,0]^t,3I), \\\\\n",
    "p([x_1, x_2]^t |\\omega_3) ∼ N([6,6]^t,4I),$\n",
    "\n",
    "#### Means of the sample distributions for 2-dimensional features:\n",
    "\n",
    "$ \\pmb{\\mu}_{\\,1} = \\bigg[ \n",
    "\\begin{array}{c}\n",
    "0 \\\\\n",
    "0 \\\\\n",
    "\\end{array} \\bigg] $,\n",
    "$ \\; \\pmb{\\mu}_{\\,2} = \\bigg[ \n",
    "\\begin{array}{c}\n",
    "9 \\\\\n",
    "0 \\\\\n",
    "\\end{array} \\bigg] $,\n",
    "$ \\; \\pmb{\\mu}_{\\,3} = \\bigg[ \n",
    "\\begin{array}{c}\n",
    "6 \\\\\n",
    "6 \\\\\n",
    "\\end{array} \\bigg] $\n",
    "\n",
    "\n",
    "#### Covariance matrices for the statistically independend and identically distributed ('i.i.d') features: \n",
    "\n",
    "$ \\Sigma_i = \\bigg[ \n",
    "\\begin{array}{cc}\n",
    "\\sigma_{11}^2 & \\sigma_{12}^2\\\\\n",
    "\\sigma_{21}^2 & \\sigma_{22}^2 \\\\\n",
    "\\end{array} \\bigg] \\\\  \n",
    "\\Sigma_1 = \\bigg[ \n",
    "\\begin{array}{cc}\n",
    "3 & 0\\\\\n",
    "0 & 3 \\\\\n",
    "\\end{array} \\bigg] \\\\\n",
    "\\Sigma_2 = \\bigg[ \n",
    "\\begin{array}{cc}\n",
    "3 & 0\\\\\n",
    "0 & 3 \\\\\n",
    "\\end{array} \\bigg] \\\\\n",
    "\\Sigma_3 = \\bigg[ \n",
    "\\begin{array}{cc}\n",
    "4 & 0\\\\\n",
    "0 & 4 \\\\\n",
    "\\end{array} \\bigg] \\\\$\n",
    "\n",
    "#### Equal prior probabilities\n",
    "$P(\\omega_1\\; |\\; \\pmb x) \\; = \\;  P(\\omega_2\\; |\\; \\pmb x) \\; = \\; P(\\omega_3\\; |\\; \\pmb x) \\; = \\frac{1}{3}$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<br>\n",
    "<br>\n",
    "<a name='sample_data'></a>\n",
    "## Generating some sample data\n",
    "Given those information, let us draw some random data from a Gaussian distribution."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "\n",
    "np.random.seed(123456)\n",
    "\n",
    "# Generate 100 random patterns for class1\n",
    "mu_vec1 = np.array([[0],[0]])\n",
    "cov_mat1 = np.array([[3,0],[0,3]])\n",
    "x1_samples = np.random.multivariate_normal(mu_vec1.ravel(), cov_mat1, 100)\n",
    "\n",
    "# Generate 100 random patterns for class2\n",
    "mu_vec2 = np.array([[9],[0]])\n",
    "cov_mat2 = np.array([[3,0],[0,3]])\n",
    "x2_samples = np.random.multivariate_normal(mu_vec2.ravel(), cov_mat2, 100)\n",
    "\n",
    "# Generate 100 random patterns for class3\n",
    "mu_vec3 = np.array([[6],[6]])\n",
    "cov_mat3 = np.array([[4,0],[0,4]])\n",
    "x3_samples = np.random.multivariate_normal(mu_vec3.ravel(), cov_mat3, 100)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "<br>\n",
    "<br>\n",
    "<a name='plotting_data'></a>\n",
    "## Plotting the sample data\n",
    "To get an intuitive idea of how our data looks like, let us visualize it in a simple scatter plot."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Populating the interactive namespace from numpy and matplotlib\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoA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6SNChpWNILEfEfdb6PrlRgGghGoE0QjMD0MMYIAECCYARKzvbv2X5KlaXj\ndth+MOuagDyjKxUAgAQtRgAAEgQjAAAJghEAgATBCABAgmAEACBBMAIAkCAYAQBIEIwAACQIRgAA\nEv8P/DLieXrTymQAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1092a19e8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%pylab inline\n",
    "\n",
    "import numpy as np\n",
    "from matplotlib import pyplot as plt\n",
    "\n",
    "f, ax = plt.subplots(figsize=(7, 7))\n",
    "ax.scatter(x1_samples[:,0], x1_samples[:,1], marker='o', color='green', s=40, alpha=0.5, label='$\\omega_1$')\n",
    "ax.scatter(x2_samples[:,0], x2_samples[:,1], marker='s', color='blue', s=40, alpha=0.5, label='$\\omega_2$')\n",
    "ax.scatter(x3_samples[:,0], x3_samples[:,1], marker='^', color='red', s=40, alpha=0.5, label='$\\omega_2$')\n",
    "plt.legend(loc='upper right') \n",
    "plt.title('Training Dataset', size=20)\n",
    "plt.ylabel('$x_2$', size=20)\n",
    "plt.xlabel('$x_1$', size=20)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<br>\n",
    "<br>\n",
    "<a name='objective_function'></a>\n",
    "\n",
    "## Defining the objective function and decision rule\n",
    "\n",
    "Here, our **objective function** is to maximize the discriminant function $g_i(\\pmb x)$, which we define as the posterior probability to perform a **minimum-error classification** (Bayes classifier). \n",
    "\n",
    "$ g_1(\\pmb x) = P(\\omega_1 | \\; \\pmb{x}), \\quad  g_2(\\pmb{x}) = P(\\omega_2 | \\; \\pmb{x}), \\quad  g_3(\\pmb{x}) = P(\\omega_2 | \\; \\pmb{x})$\n",
    "\n",
    "So that our decision rule is to choose the class $\\omega_i$ for which $g_i(\\pmb x)$ is max., where  \n",
    " $ \\quad g_i(\\pmb{x}) = \\pmb{x}^{\\,t} \\bigg( - \\frac{1}{2} \\Sigma_i^{-1} \\bigg) \\pmb{x} + \\bigg( \\Sigma_i^{-1} \\pmb{\\mu}_{\\,i}\\bigg)^t \\pmb x + \\bigg( -\\frac{1}{2} \\pmb{\\mu}_{\\,i}^{\\,t}  \\Sigma_{i}^{-1} \\pmb{\\mu}_{\\,i} -\\frac{1}{2} ln(|\\Sigma_i|)\\bigg) $"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<br>\n",
    "<br>\n",
    "<a name='discriminant_functions'></a>\n",
    "## Implementing the discriminant function\n",
    "Now, let us implement the discriminant function for $g_i(\\pmb x)$ in Python code:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def discriminant_function(x_vec, cov_mat, mu_vec):\n",
    "    \"\"\"\n",
    "    Calculates the value of the discriminant function for a dx1 dimensional\n",
    "    sample given the covariance matrix and mean vector.\n",
    "    \n",
    "    Keyword arguments:\n",
    "        x_vec: A dx1 dimensional numpy array representing the sample.\n",
    "        cov_mat: numpy array of the covariance matrix.\n",
    "        mu_vec: dx1 dimensional numpy array of the sample mean.\n",
    "    \n",
    "    Returns a float value as result of the discriminant function.\n",
    "    \n",
    "    \"\"\"\n",
    "    W_i = (-1/2) * np.linalg.inv(cov_mat)\n",
    "    assert(W_i.shape[0] > 1 and W_i.shape[1] > 1), 'W_i must be a matrix'\n",
    "    \n",
    "    w_i = np.linalg.inv(cov_mat).dot(mu_vec)\n",
    "    assert(w_i.shape[0] > 1 and w_i.shape[1] == 1), 'w_i must be a column vector'\n",
    "    \n",
    "    omega_i_p1 = (((-1/2) * (mu_vec).T).dot(np.linalg.inv(cov_mat))).dot(mu_vec)\n",
    "    omega_i_p2 = (-1/2) * np.log(np.linalg.det(cov_mat))\n",
    "    omega_i = omega_i_p1 - omega_i_p2\n",
    "    assert(omega_i.shape == (1, 1)), 'omega_i must be a scalar'\n",
    "    \n",
    "    g = ((x_vec.T).dot(W_i)).dot(x_vec) + (w_i.T).dot(x_vec) + omega_i\n",
    "    return float(g)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<br>\n",
    "<br>\n",
    "<a name='decision_rule'></a>\n",
    "## Implementing the decision rule (classifier)\n",
    "Next, we need to implement the code that returns the max. $g_i(\\pmb x)$ with the corresponding class label:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import operator\n",
    "\n",
    "def classify_data(x_vec, g, mu_vecs, cov_mats):\n",
    "    \"\"\"\n",
    "    Classifies an input sample into 1 out of 3 classes determined by\n",
    "    maximizing the discriminant function g_i().\n",
    "    \n",
    "    Keyword arguments:\n",
    "        x_vec: A dx1 dimensional numpy array representing the sample.\n",
    "        g: The discriminant function.\n",
    "        mu_vecs: A list of mean vectors as input for g.\n",
    "        cov_mats: A list of covariance matrices as input for g.\n",
    "    \n",
    "    Returns a tuple (g_i()_value, class label).\n",
    "    \n",
    "    \"\"\"\n",
    "    assert(len(mu_vecs) == len(cov_mats)), 'Number of mu_vecs and cov_mats must be equal.'\n",
    "    \n",
    "    g_vals = []\n",
    "    for m,c in zip(mu_vecs, cov_mats): \n",
    "        g_vals.append(g(x_vec, mu_vec=m, cov_mat=c))\n",
    "    \n",
    "    max_index, max_value = max(enumerate(g_vals), key=operator.itemgetter(1))\n",
    "    return (max_value, max_index + 1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<br>\n",
    "<br>\n",
    "<a name='classifying'></a>\n",
    "## Classifying the sample data\n",
    "Using the discriminant function and classifier that we just implemented above, let us classify our sample data. (I have to apologize for the long code below, but I thought it makes it a little more clear of what exactly is going on)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "class1_as_1 = 0\n",
    "class1_as_2 = 0\n",
    "class1_as_3 = 0\n",
    "for row in x1_samples:\n",
    "    g = classify_data(\n",
    "        row, \n",
    "        discriminant_function,\n",
    "        [mu_vec1, mu_vec2, mu_vec3],\n",
    "        [cov_mat1, cov_mat2, cov_mat3]\n",
    "    )\n",
    "    if g[1] == 2:\n",
    "        class1_as_2 += 1\n",
    "    elif g[1] == 3:\n",
    "        class1_as_3 += 1\n",
    "    else:\n",
    "        class1_as_1 += 1\n",
    "\n",
    "class2_as_1 = 0\n",
    "class2_as_2 = 0\n",
    "class2_as_3 = 0\n",
    "for row in x2_samples:\n",
    "    g = classify_data(\n",
    "        row, \n",
    "        discriminant_function,\n",
    "        [mu_vec1, mu_vec2, mu_vec3],\n",
    "        [cov_mat1, cov_mat2, cov_mat3]\n",
    "    )\n",
    "    if g[1] == 2:\n",
    "        class2_as_2 += 1\n",
    "    elif g[1] == 3:\n",
    "        class2_as_3 += 1\n",
    "    else:\n",
    "        class2_as_1 += 1\n",
    "\n",
    "class3_as_1 = 0\n",
    "class3_as_2 = 0\n",
    "class3_as_3 = 0\n",
    "for row in x3_samples:\n",
    "    g = classify_data(\n",
    "        row, \n",
    "        discriminant_function,\n",
    "        [mu_vec1, mu_vec2, mu_vec3],\n",
    "        [cov_mat1, cov_mat2, cov_mat3]\n",
    "    )\n",
    "    if g[1] == 2:\n",
    "        class3_as_2 += 1\n",
    "    elif g[1] == 3:\n",
    "        class3_as_3 += 1\n",
    "    else:\n",
    "        class3_as_1 += 1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<br>\n",
    "<br>\n",
    "<a name='confusion matrix'></a>\n",
    "## Drawing the confusion matrix and calculating the empirical error\n",
    "Now, that we classified our data, let us plot the confusion matrix to see what the empirical error looks like."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "ename": "ImportError",
     "evalue": "No module named 'prettytable'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mImportError\u001b[0m                               Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-6-a1e77b34b2e8>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mprettytable\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      2\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      3\u001b[0m \u001b[0mconfusion_mat\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mprettytable\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mPrettyTable\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"sample dataset\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"w1 (predicted)\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"w2 (predicted)\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"w3 (predicted)\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      4\u001b[0m \u001b[0mconfusion_mat\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd_row\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"w1 (actual)\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mclass1_as_1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mclass1_as_2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mclass1_as_3\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      5\u001b[0m \u001b[0mconfusion_mat\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd_row\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"w2 (actual)\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mclass2_as_1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mclass2_as_2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mclass2_as_3\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mImportError\u001b[0m: No module named 'prettytable'"
     ]
    }
   ],
   "source": [
    "import prettytable\n",
    "\n",
    "confusion_mat = prettytable.PrettyTable([\"sample dataset\", \"w1 (predicted)\", \"w2 (predicted)\", \"w3 (predicted)\"])\n",
    "confusion_mat.add_row([\"w1 (actual)\",class1_as_1, class1_as_2, class1_as_3])\n",
    "confusion_mat.add_row([\"w2 (actual)\",class2_as_1, class2_as_2, class2_as_3])\n",
    "confusion_mat.add_row([\"w3 (actual)\",class3_as_1, class3_as_2, class3_as_3])\n",
    "print(confusion_mat)\n",
    "misclass = x1_samples.shape[0]*3 - class1_as_1 - class2_as_2 - class3_as_3\n",
    "bayes_err = misclass / (len(x1_samples)*3)\n",
    "print('Empirical Error: {:.2f} ({:.2f}%)'.format(bayes_err, bayes_err * 100))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<br>\n",
    "<br>\n",
    "<a name='two'></a>\n",
    "# 2) Assuming that the parameters are unknown - using MLE"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<br>\n",
    "<br>\n",
    "<a name='about_mle'></a>\n",
    "### About the Maximum Likelihood Estimate (MLE)\n",
    "\n",
    "In contrast to the first section, let us assume that we only know the number of parameters for the class conditional densities $p (\\; \\pmb x \\; | \\; \\omega_i)$, and we want to use a Maximum Likelihood Estimation (MLE) to estimate the quantities of these parameters from the training data (*here:* our random sample data).\n",
    "\n",
    "\n",
    "Given the information about the form of the model - the data is normal distributed - the 2 parameters to be estimated are $\\pmb \\mu_i$ and $\\pmb \\Sigma_i$, which are summarized by the   \n",
    "parameter vector $\\pmb \\theta_i = \\bigg[ \\begin{array}{c}\n",
    "\\ \\theta_{i1} \\\\\n",
    "\\ \\theta_{i2} \\\\\n",
    "\\end{array} \\bigg]=\n",
    "\\bigg[ \\begin{array}{c}\n",
    "\\pmb \\mu_i \\\\\n",
    "\\pmb \\Sigma_i \\\\\n",
    "\\end{array} \\bigg]$ "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For the Maximum Likelihood Estimate (MLE), we assume that we have a set of samples $D = \\left\\{ \\pmb x_1, \\pmb x_2,..., \\pmb x_n \\right\\} $ that are *i.i.d.* (independent and identically distributed, drawn with probability $p(\\pmb x \\; | \\; \\omega_i, \\; \\pmb \\theta_i) $).  \n",
    "Thus, we can **work with each class separately** and omit the class labels, so that we write the probability density as $p(\\pmb x \\; | \\; \\pmb \\theta)$ "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<br>\n",
    "<br>\n",
    "### Likelihood of $ \\pmb \\theta $"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Thus, the probability of observing $D = \\left\\{ \\pmb x_1, \\pmb x_2,..., \\pmb x_n \\right\\} $ is: \n",
    "<br>\n",
    "<br>\n",
    "$p(D\\; | \\;  \\pmb \\theta\\;) = p(\\pmb x_1 \\; | \\; \\pmb \\theta\\;)\\; \\cdot \\; p(\\pmb x_2 \\; | \\;\\pmb \\theta\\;) \\; \\cdot \\;...  \\; p(\\pmb x_n \\; | \\; \\pmb \\theta\\;) = \\prod_{k=1}^{n} \\; p(\\pmb x_k \\pmb \\; | \\; \\pmb \\theta \\;)$  \n",
    "<br>\n",
    "Where $p(D\\; | \\;  \\pmb  \\theta\\;)$ is also called the ***likelihood of $\\pmb\\ \\theta$***."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We are given the information that $p([x_1,x_2]^t) \\;∼ \\; N(\\pmb \\mu,\\pmb \\Sigma) $ (remember that we dropped the class labels, since we are working with every class separately)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And the mutlivariate normal density is given as:\n",
    "$\\quad \\quad p(\\pmb x) = \\frac{1}{(2\\pi)^{d/2} \\; |\\Sigma|^{1/2}} exp \\bigg[ -\\frac{1}{2}(\\pmb x - \\pmb \\mu)^t \\Sigma^{-1}(\\pmb x - \\pmb \\mu) \\bigg]$\n",
    "\n",
    "So that  \n",
    "$p(D\\; | \\;  \\pmb \\theta\\;) = \\prod_{k=1}^{n} \\; p(\\pmb x_k \\pmb \\; | \\; \\pmb \\theta \\;) =  \\prod_{k=1}^{n} \\; \\frac{1}{(2\\pi)^{d/2} \\; |\\Sigma|^{1/2}} exp \\bigg[ -\\frac{1}{2}(\\pmb x - \\pmb \\mu)^t \\Sigma^{-1}(\\pmb x - \\pmb \\mu) \\bigg]$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "and the log of the multivariate density"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$ l(\\pmb\\theta) =  \\sum\\limits_{k=1}^{n} - \\frac{1}{2}(\\pmb x - \\pmb \\mu)^t \\pmb \\Sigma^{-1} \\; (\\pmb x - \\pmb \\mu) - \\frac{d}{2} \\; ln \\; 2\\pi - \\frac{1}{2} \\;ln \\; |\\pmb\\Sigma|$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<br>\n",
    "<br>\n",
    "#### Maximum Likelihood Estimate (MLE)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In order to obtain the MLE $\\boldsymbol{\\hat{\\theta}}$, we maximize $l (\\pmb  \\theta)$, which can be done via differentiation:\n",
    "\n",
    "with \n",
    "$\\nabla_{\\pmb \\theta} \\equiv \\begin{bmatrix}  \n",
    "\\frac{\\partial \\; }{\\partial \\; \\theta_1} \\\\ \n",
    "\\frac{\\partial \\; }{\\partial \\; \\theta_2}\n",
    "\\end{bmatrix} = \\begin{bmatrix} \n",
    "\\frac{\\partial \\; }{\\partial \\; \\pmb \\mu} \\\\ \n",
    "\\frac{\\partial \\; }{\\partial \\; \\pmb \\sigma}\n",
    "\\end{bmatrix}$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$\\nabla_{\\pmb \\theta} l = \\sum\\limits_{k=1}^n \\nabla_{\\pmb \\theta} \\;ln\\; p(\\pmb x| \\pmb \\theta) = 0 $"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<br>\n",
    "<br>\n",
    "<a name='mle_mu'></a>\n",
    "## MLE of the mean vector $\\pmb \\mu$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "After doing the differentiation, we find that the MLE of the parameter $\\pmb\\mu$ is given by the equation:  \n",
    "${\\hat{\\pmb\\mu}} = \\frac{1}{n} \\sum\\limits_{k=1}^{n} \\pmb x_k$\n",
    "\n",
    "As you can see, this is simply the mean of our dataset, so we can implement the code very easily and compare the estimate to the actual values for $\\pmb \\mu$."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import prettytable\n",
    "\n",
    "mu_est1 = np.array([[sum(x1_samples[:,0])/len(x1_samples[:,0])],[sum(x1_samples[:,1])/len(x1_samples[:,1])]])\n",
    "mu_est2 = np.array([[sum(x2_samples[:,0])/len(x2_samples[:,0])],[sum(x2_samples[:,1])/len(x2_samples[:,1])]])\n",
    "mu_est3 = np.array([[sum(x3_samples[:,0])/len(x3_samples[:,0])],[sum(x3_samples[:,1])/len(x3_samples[:,1])]])\n",
    "\n",
    "mu_mle = prettytable.PrettyTable([\"\", \"mu_1\", \"mu_2\", \"mu_3\"])\n",
    "mu_mle.add_row([\"MLE\",mu_est1, mu_est2, mu_est3])\n",
    "mu_mle.add_row([\"actual\",mu_vec1, mu_vec2, mu_vec3])\n",
    "\n",
    "print(mu_mle)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<br>\n",
    "<br>\n",
    "<a name='mle_cov'></a>\n",
    "## MLE of the covariance matrix $\\pmb \\Sigma$\n",
    "\n",
    "Analog to $\\pmb \\mu$ we can find the equation for the $\\pmb\\Sigma$ via differentiation - okay the equations are a little bit more involved, but the approach is the same - so that we come to this equation:  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "${\\hat{\\pmb\\Sigma}} = \\frac{1}{n} \\sum\\limits_{k=1}^{n} (\\pmb x_k - \\hat{\\mu})(\\pmb x_k - \\hat{\\mu})^t$\n",
    "\n",
    "which we will also implement in Python code, and then compare to the acutal values of ${\\pmb\\Sigma}$."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import prettytable\n",
    "\n",
    "def mle_est_cov(x_samples, mu_est):\n",
    "    \"\"\"\n",
    "    Calculates the Maximum Likelihood Estimate for the covariance matrix.\n",
    "    \n",
    "    Keyword Arguments:\n",
    "        x_samples: np.array of the samples for 1 class, n x d dimensional \n",
    "        mu_est: np.array of the mean MLE, d x 1 dimensional\n",
    "        \n",
    "    Returns the MLE for the covariance matrix as d x d numpy array.\n",
    "    \n",
    "    \"\"\"\n",
    "    cov_est = np.zeros((2,2))\n",
    "    for x_vec in x_samples:\n",
    "        x_vec = x_vec.reshape(2,1)\n",
    "        assert(x_vec.shape == mu_est.shape), 'mean and x vector hmust be of equal shape'\n",
    "        cov_est += (x_vec - mu_est).dot((x_vec - mu_est).T)\n",
    "    return cov_est / len(x_samples)\n",
    "\n",
    "cov_est1 = mle_est_cov(x1_samples, mu_est1)\n",
    "cov_est2 = mle_est_cov(x2_samples, mu_est2)\n",
    "cov_est3 = mle_est_cov(x3_samples, mu_est3)\n",
    "\n",
    "cov_mle = prettytable.PrettyTable([\"\", \"covariance_matrix_1\", \"covariance_matrix_2\", \"covariance_matrix_3\"])\n",
    "cov_mle.add_row([\"MLE\", cov_est1, cov_est2, cov_est3])\n",
    "cov_mle.add_row(['','','',''])\n",
    "cov_mle.add_row([\"actual\", cov_mat1, cov_mat2, cov_mat3])\n",
    "\n",
    "print(cov_mle)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<br>\n",
    "<br>\n",
    "<a name='classifying_mle'></a>\n",
    "\n",
    "## Classification using our estimated parameters\n",
    "\n",
    "Using the estimated parameters $\\pmb \\mu_i$ and $\\pmb \\Sigma_i$, which we obtained via MLE, we calculate the error on the sample dataset again. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "class1_as_1 = 0\n",
    "class1_as_2 = 0\n",
    "class1_as_3 = 0\n",
    "for row in x1_samples:\n",
    "    g = classify_data(\n",
    "        row, \n",
    "        discriminant_function,\n",
    "        [mu_est1, mu_est2, mu_est3],\n",
    "        [cov_est1, cov_est2, cov_est3]\n",
    "    )\n",
    "    if g[1] == 2:\n",
    "        class1_as_2 += 1\n",
    "    elif g[1] == 3:\n",
    "        class1_as_3 += 1\n",
    "    else:\n",
    "        class1_as_1 += 1\n",
    "\n",
    "class2_as_1 = 0\n",
    "class2_as_2 = 0\n",
    "class2_as_3 = 0\n",
    "for row in x2_samples:\n",
    "    g = classify_data(\n",
    "        row, \n",
    "        discriminant_function,\n",
    "        [mu_est1, mu_est2, mu_est3],\n",
    "        [cov_est1, cov_est2, cov_est3]\n",
    "    )\n",
    "    if g[1] == 2:\n",
    "        class2_as_2 += 1\n",
    "    elif g[1] == 3:\n",
    "        class2_as_3 += 1\n",
    "    else:\n",
    "        class2_as_1 += 1\n",
    "\n",
    "class3_as_1 = 0\n",
    "class3_as_2 = 0\n",
    "class3_as_3 = 0\n",
    "for row in x3_samples:\n",
    "    g = classify_data(\n",
    "        row, \n",
    "        discriminant_function,\n",
    "        [mu_est1, mu_est2, mu_est3],\n",
    "        [cov_est1, cov_est2, cov_est3]\n",
    "    )\n",
    "    if g[1] == 2:\n",
    "        class3_as_2 += 1\n",
    "    elif g[1] == 3:\n",
    "        class3_as_3 += 1\n",
    "    else:\n",
    "        class3_as_1 += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import prettytable\n",
    "\n",
    "confusion_mat = prettytable.PrettyTable([\"sample dataset\", \"w1 (predicted)\", \"w2 (predicted)\", \"w3 (predicted)\"])\n",
    "confusion_mat.add_row([\"w1 (actual)\",class1_as_1, class1_as_2, class1_as_3])\n",
    "confusion_mat.add_row([\"w2 (actual)\",class2_as_1, class2_as_2, class2_as_3])\n",
    "confusion_mat.add_row([\"w3 (actual)\",class3_as_1, class3_as_2, class3_as_3])\n",
    "print(confusion_mat)\n",
    "misclass = x1_samples.shape[0]*3 - class1_as_1 - class2_as_2 - class3_as_3\n",
    "bayes_err = misclass / (len(x1_samples)*3)\n",
    "print('Empirical Error: {:.2f} ({:.2f}%)'.format(bayes_err, bayes_err * 100))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<br>\n",
    "<br>\n",
    "<a name='conclusion'></a>\n",
    "## Conclusion"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "I would claim that the results look pretty good! The error rate on our random dataset increased by just 0.67% (from 4.00% to 4.67%) when we estimated $\\pmb \\mu$ and $\\pmb \\Sigma$ using MLE.  \n",
    "In a real application of course, we would have an separate training dataset to derive and estimate the parameters, and a test data set for calculating the error rate. However, I ommitted the usage of to separate datasets here for the sake of brevity."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
